package controllers

import (
	"net/http"

	beego "github.com/beego/beego/v2/server/web"
)

type IndexController struct {
	beego.Controller
}

func (c *IndexController) Index() {

	if c.GetSession("username") == nil {
		//c.Ctx.WriteString("Please login")
		c.TplName = "user/login.html"
		return
	}

	c.Data["json"] = map[string]interface{}{
		"code":     http.StatusOK,
		"msg":      "ok",
		"username": c.GetSession("username"),
	}
	c.ServeJSON()
}
